package logic

import (
	"context"
	"house_srv/models"

	"house_srv/house"
	"house_srv/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewUserListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserListLogic {
	return &UserListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 用户展示
func (l *UserListLogic) UserList(in *house.UserListRequest) (*house.UserListResponse, error) {
	// todo: add your logic here and delete this line
	var user []models.User
	models.DB.Where("status=?", in.Status).Find(&user)
	var userlist []*house.UserList
	for _, m := range user {
		list := house.UserList{
			Phone:    m.Phone,
			Password: m.Password,
			Status:   m.Status,
		}
		userlist = append(userlist, &list)
	}
	return &house.UserListResponse{
		List: userlist,
	}, nil
}
